package cn.joker.controller;

import cn.joker.util.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/redis")
public class RedisTestController {

    @Autowired
    private RedisUtils redisUtils;

    @GetMapping("/set")
    public String set() {
        redisUtils.set("test:key", "Hello Redis", 60, TimeUnit.SECONDS);
        return "ok";
    }

    @GetMapping("/get")
    public Object get() {
        return redisUtils.get("test:key");
    }
}
